﻿#ifndef CSERIALPORT_H
#define CSERIALPORT_H
#include <QSerialPort>
#include <QSerialPortInfo>
#include <QObject>
#include <QMutex>
#include <QTimer>
class CSerialPort: public QObject
{
    Q_OBJECT
public:
    CSerialPort();

    int SerialPort_Init(QString PortName,int BaudRate);
    void Read_Data();
    int SerialPort_Write(int size,char *buffer);
    int SerialPort_Close();


    QSerialPort serial;
    QTimer * timer;
    QByteArray buffer;

private slots:
    void readMyCom();


signals:
    void update_serial_data();
};

extern CSerialPort *g_serial_port;
extern bool g_IsRunSerial;

extern int g_serial_size;
extern unsigned char g_serial_data[256];
extern QMutex g_mutex_serial_update;

#endif // CSERIALPORT_H
